package org.jeecg.modules.api.wlhy.app.utils;

import java.io.IOException;

public class SMUtils {

    /**
     * 报文解密，对称加密报文，非对称加密秘钥
     * @param privateKey
     * @param encryptedCode
     * @param encryptedContent
     * @return
     * @throws IOException
     */
    public static String untieDoubleEncryptionCiphertext(
            String privateKey,String encryptedCode,String encryptedContent ) throws Exception {
        String aesKey = new String(SM2Util.decrypt(Util.hexToByte(privateKey), Util.hexToByte(encryptedCode)));
        SM4Util sm4 = new SM4Util();
        sm4.secretKey = aesKey;
        sm4.hexString = false;
        String content = sm4.decryptData_ECB(encryptedContent);
        return content;
    }

}
